#include "CocosPCH.h"
#include "BaseViewer.h"


BaseViewer::BaseViewer()
: m_bHasExportOne(false)
, m_bHasExportAll(false)
, m_bInitUI(false)
{
}

bool BaseViewer::init()
{
    if (!Layer::init())
        return false;

    m_pViewNode = Layer::create();
    addChild(m_pViewNode);

    m_pUINode = Layer::create();
    addChild(m_pUINode);

    return true;
}

bool BaseViewer::initUI()
{
    m_bInitUI = true;
    m_pViewNode->setContentSize(getContentSize());
    return true; 
}

bool BaseViewer::LoadFile(std::string strPath)
{
    m_strFilePath = strPath;
    m_pViewNode->removeAllChildrenWithCleanup(true);
    return true;
}

ui::Widget* BaseViewer::createItem(int nIndex, std::string strName)
{
    auto button = ui::Button::create("Button_Normal.png");
    button->setContentSize(Size(104, 104));
    button->setScale9Enabled(true);
    button->setTitleText(StringUtils::toString(nIndex));
    button->setTitleFontSize(50);
    button->setTitleColor(Color3B(0, 0, 0));

    return button;
}